/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2022-10-10
 * Time: 8:37
 */
class Student{
        public int score;
        public String name;
        public Student(String name,int score){
            this.name = name;
            this.score = score;
        }
    public boolean equals(Object obj) {
        if (obj == null) {
            return false ;
        }
        if(this == obj) {
            return true ;
        }
        // 不是Person类对象
        if (!(obj instanceof Student)) {
            return false ;
        }
       Student student = (Student) obj ; // 向下转型，比较属性值
        return this.name.equals(student.name) && this.score==student.score ;
    }

    @Override
    public String toString() {
        return "Student{" +
                "score=" + score +
                ", name='" + name + '\'' +
                '}';
    }
}
public class Test {

    public static void main(String[] args) {
      Student s1 = new Student("白糖",100);
      Student s2 = new Student("白糖",100);
        System.out.println(s1.equals(s2));
        System.out.println(s1);
    }
}
